package com.itheima.edu.info.manager.factory;

import com.itheima.edu.info.manager.dao.TeacherDao;

import java.util.ResourceBundle;

public class TeacherFactory {
    //注意: 当方法的返回值类型是一个接口类型时,方法中需要返回的是该接口的实现类对象
    public static TeacherDao getTeacherDao1() {
        return new TeacherDao();
    }

    public static TeacherDao getTeacherDao() {
        try {
            ResourceBundle bundle = ResourceBundle.getBundle("prop");
            Class clazz = Class.forName(bundle.getString("TeacherName"));
            return (TeacherDao) clazz.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}


